/*
 *  collisionTest.h
 *  
 *
 *  Created by Christoffer Svahn on 4/20/11.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */

void boundingSphere(PlayerObject *obj1, PlayerObject *obj2){
	float d;
	float xDistance = (obj1->pos.x + obj1->mesh->meshCenter.x) - (obj2->pos.x + obj2->mesh->meshCenter.x);
	float yDistance = (obj1->pos.y + obj1->mesh->meshCenter.y) - (obj2->pos.y + obj2->mesh->meshCenter.y);
	float zDistance = (obj1->pos.z + obj1->mesh->meshCenter.z) - (obj2->pos.z + obj2->mesh->meshCenter.z);
	d = sqrt(
			 pow(xDistance,2) +
			 pow(yDistance,2) +
			 pow(zDistance,2)
			);
	if(d <= obj1->mesh->radius + obj2->mesh->radius){
		//Krocken sker, vad händer?
	}
}

int checkCollision(float r1, Location pos1, XYZ center1, float r2, Location pos2, XYZ center2){
	float xDistance = (pos1.x + center1.x) - (pos2.x + center2.x);
	float yDistance = (pos1.y + center1.y) - (pos2.y + center2.y);
	float zDistance = (pos1.z + center1.z) - (pos2.z + center2.z);
	
	float d = sqrt(pow(xDistance,2) + pow(yDistance,2) + pow(zDistance,2));

	if(d <= r1 + r2){
		return 1;
	}
	else {
		return 0;
	}
}